package recordProcessing;
import java.util.ArrayList;
import java.util.Date;

import data.AbstractDataType;

import fields.AbstractField;
import fields.FieldMatcher;

public abstract class Record {

	private long baseID = 0;
	private String recordID;
	private ArrayList<AbstractField> field;
	private ArrayList<AbstractDataType> data;
	
	public Record(){
		recordID = (new Date().toString())+(baseID++);//current date + counter
	}
	
	public Record(String fieldname,String val){
		recordID = (new Date().toString())+(baseID++);
		AbstractField f = FieldMatcher.getField(fieldname);
		if(f != null)
			;//add data with data class
		
	}
	
	public Record(ArrayList<AbstractField> f, ArrayList<AbstractDataType> d){
		recordID = (new Date().toString())+(baseID++);
		field=(ArrayList<AbstractField>) f.clone();
		data=(ArrayList<AbstractDataType>) d.clone();
	}
	
	public String getRecordID() {
		return recordID;
	}
	
	public String toCSV(String delimiter){
		String output="";
		for(AbstractDataType d : data){
			output+=data.toString()+delimiter+"\r\n";
		}
		return output;
	}

}